package com.ruoyi.eqmonitor.controller;

import java.util.List;

import com.ruoyi.eqmonitor.domain.OptSewageRenovate;
import com.ruoyi.eqmonitor.service.OptSewageRenovateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.Arrays;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.security.utils.SecurityUtils;

import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 镇街道排污（水）口整治情况
 * @author ruoyi
 * @date 2023-02-08
 */
@RestController
@RequestMapping("/sewageRenovate")
public class OptSewageRenovateController extends BaseController{
    
    @Autowired
    private OptSewageRenovateService optSewageRenovateService;

    @GetMapping("/list")
    public TableDataInfo<?> list(OptSewageRenovate optSewageRenovate){
        startPage();
        List<OptSewageRenovate> list = optSewageRenovateService.selectOptSewageRenovateList(optSewageRenovate);
        return getDataTable(list);
    }

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id){
        return AjaxResult.success(optSewageRenovateService.selectOptSewageRenovateById(id));
    }

    @Log(title = "镇街道排污（水）口整治情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OptSewageRenovate optSewageRenovate){
        return toAjax(optSewageRenovateService.save(optSewageRenovate));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody OptSewageRenovate optSewageRenovate){
        return toAjax(optSewageRenovateService.updateById(optSewageRenovate));
    }

    /**
     * 传入@PathVariable的格式类似为/1,2,3,4,5时,会自动转为数组
     */
    @Log(title = "镇街道排污（水）口整治情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(optSewageRenovateService.removeByIds(Arrays.asList(ids)));
    }
    
    /**
     * 导出镇街道排污（水）口整治情况列表
     */
    @Log(title = "镇街道排污（水）口整治情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OptSewageRenovate optSewageRenovate){
        List<OptSewageRenovate> list = optSewageRenovateService.selectOptSewageRenovateList(optSewageRenovate);
        ExcelUtil<OptSewageRenovate> util = new ExcelUtil<OptSewageRenovate>(OptSewageRenovate.class);
        util.exportExcel(response, list, "镇街道排污（水）口整治情况数据");
    }
    
}
